/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dvdfe8.crochet.modelo.service;

import com.dvdfe8.crochet.modelo.dao.LineaDao;
import com.dvdfe8.crochet.modelo.entity.Amigurumi;
import com.dvdfe8.crochet.modelo.entity.Linea;
import com.dvdfe8.crochet.modelo.entity.Pedido;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author David
 */
@Service
public class LineaServiceImpl implements LineaService {

    @Autowired
    LineaDao lineaDao;
    
    @Autowired
    AmigurumiService amigurumiService;

    @Override
    public void crear(Linea linea) {        
        Amigurumi amigurumi = amigurumiService.getAmigurumiById(linea.getAmigurumiId());
        linea.setAmigurumi(amigurumi);
        lineaDao.crear(linea);
    }

    @Override
    public void eliminar(Linea linea) {
        lineaDao.eliminar(linea);
    }

    @Override
    public Linea getLineaById(int id) {
        return lineaDao.getLineaById(id);
    }

    @Override
    public List<Linea> getLineasByPedido(Pedido pedido) {
        return lineaDao.getLineasByPedido(pedido);
    }

}
